<?php

namespace App\Supports\Product;

use Illuminate\Support\Facades\Storage;

class ProductPosterCleaner
{
	public function clear($product, $requestSkus)
	{
		foreach($requestSkus as $k => $v){
			if(!empty($v['id'])) {
				$productSku = $product->skus()->find($v['id']);
				if($v['price_cost'] != $productSku->price_cost
					|| $v['price'] != $productSku->price
					|| $v['price_vip'] != $productSku->price_vip){
					Storage::deleteDirectory('images/mini-product-invite-posters');
					break;
				}
			}
		}
	}
}
